package src.leetcode.greedy.simple_0455;

import java.util.Arrays;

public class findContentChildren {
    public static void main(String[] args) {
        Solution solution = new Solution();
        System.out.println(solution.findContentChildren(new int[]{1, 2, 3}, new int[]{1, 1}));
    }
}

class Solution {
    public int findContentChildren(int[] g, int[] s) {
        Arrays.sort(g);
        Arrays.sort(s);
        int count = 0;
        int i = g.length - 1;
        int j = s.length - 1;
        while (i >= 0 && j >= 0){

            if (g[i] <= s[j]){
                i--;
                j--;
                count++;
            }else {
                i--;
            }
        }

        return count;
    }
}

